package com.bustle.product.dto.product;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import com.bustle.commons.MapConverter;
import com.bustle.product.data.Product;
import com.bustle.product.dto.provider.ProviderToDtoMapConverter;

@Local
public interface ProductToDtoMapConverter extends MapConverter<Product, ProductDto>
{
  @Stateless
  public class DefaultProductToDtoMapConverter extends AbstractMapConverter<Product, ProductDto> implements ProductToDtoMapConverter
  {
    @Override
    public void doMapping(Product paramASource, ProductDto paramADestination)
    {
      paramADestination.setCreationDate(paramASource.getCreationDate());
      paramADestination.setDescription(paramASource.getDescription());
      paramADestination.setIdProduct(paramASource.getIdProduct());
      paramADestination.setImage(paramASource.getImage());
      paramADestination.setLimitedDate(paramASource.getLimitedDate());
      paramADestination.setName(paramASource.getName());
      paramADestination.setPrice(paramASource.getPrice());
      paramADestination.setProductType(paramASource.getProductType());
      paramADestination.setProvider(providerToDtoConverter.map(paramASource.getProvider(), paramADestination.getProvider()));
    }

    @Override
    protected ProductDto build()
    {
      return new ProductDto();
    }

    @EJB
    protected ProviderToDtoMapConverter providerToDtoConverter;
  }
}